// pages/index/todoList/todoList.js
import {
  todoList,
} from '../../../api.js'
var app = getApp(); //获取App内部的信息
Page({
  /**
   * 页面的初始数据
   */
  data: {
    info:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  onShow:function(){
    todoList({ token: app.globalData.token }).then(res => {
      if (res.data.code == 666) {
    this.setData({
      info: res.data.data
    })
  } else if (res.data.code == 111111) {
    wx.showToast({
      title: '登录失效，请重新登录',
      icon: 'none',
    })
    setTimeout(function () {
      wx.reLaunch({
        url: '/pages/user/login/login',
      })
    }, 1500)
      } else {
        wx.showToast({
          title: res.data.msg,
          icon: 'none'
        })
      }
    })
  },
  todo(e) {
    console.log(e.currentTarget.dataset.id, e)
    let id = e.currentTarget.dataset.id;
    let info_batchcode = e.currentTarget.dataset.infobatchcode
    wx.navigateTo({
      url: '/pages/orderControl/orderDetail/orderDetail?type=todo&id=' + id + '&info_batchcode=' + info_batchcode,
    })
  },
})